/*
Document   : ui
Created on : Oct 28, 2009, 10:34:52 PM
Author     : fdcube
 */
var w;
var wakecount = 0;
var UserNameIns = null;
var MsgCount = 0;
//The Fllow Functions Will Be Called When Recieved The Data From Server
function LoginUi() {
    UserNameIns = document.getElementById("PageUserName").value;
    document.getElementById("PageLogin").innerHTML = "<b>" + document.getElementById("PageUserName").value + ",<a href=\"#\" onclick=\"LogOut()\">退出</a></b>";
}
function SendMsgUi() {
    document.getElementById("MsgContent").value = "";
//alert("Send Ok");
}
function GetMsgUi(UserName,MsgContent,MsgColor) {
    if( MsgCount > 100) {
        MsgCount = 0;
        document.getElementById("Msgs").innerHTML = "";
    }
    PageAddMsg(UserName,MsgContent,MsgColor);
    MsgCount++;
    if (UserName != UserNameIns && w == null) {
        WakeUpWindow();
    }
//document.getElementById("Msg").innerHTML = UserName + "\n" +MsgContent + "\n" + MsgColor;
}
function GetUsersUi(UserName) {
    document.getElementById("Users").innerHTML = "";
    //var tmp = "";
    for (var i in UserName) {
        CreateOnlineuser(UserName[i]);
    //tmp += UserName[i] + "  ";
    }
//document.getElementById("Users").innerHTML = tmp;
}
function LogOutUi() {
    alert("LogOut Ok");
    window.location.reload();
}

//Local Ui Function
function WakeUpWindow() {
    wakecount++;
    if (wakecount % 2 ==0) {
        window.document.title = "\u65b0\u6d88\u606f\u6765\u54af\uff01";
        w = window.setTimeout("WakeUpWindow()",1000);
    } else {
        window.document.title = "\u2192\u2190\u2606\u25cf\u2605\u2192\u2190";
        w = window.setTimeout("WakeUpWindow()", 1000);
    }
}
function SleepWindow() {
    window.document.title = "FdChat\u804a\u5929\u5ba4 \u5185\u6d4b";
    window.clearTimeout(w);
    w = null;
}